home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / DJSRC111.ZIP / go32 / tables.asm < prev    next >
Assembly Source File  |  1993-08-11  |  4KB  |  208 lines

  1. ; This is file TABLES.ASM
  2. ;
  3. ; Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. ;    History:20,1
  16.     title    tables
  17.     .386p
  18.  
  19.     include segdefs.inc
  20.     include tss.inc
  21.     include gdt.inc
  22.     include idt.inc
  23.  
  24. ;------------------------------------------------------------------------
  25.  
  26.     start_data16
  27.  
  28.     extrn    _tss_ptr:word
  29.     extrn    _was_exception:word
  30.     extrn    _npx:byte
  31.  
  32.     public  _was_user_int
  33. _was_user_int    dw    0
  34.  
  35.     public  ivec_number
  36. ivec_number    db    ?
  37.  
  38. has_error    db    0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0
  39.  
  40.     public  _vector_78h
  41. _vector_78h    db    ?
  42.     public  _vector_79h
  43. _vector_79h    db    ?
  44.  
  45.     end_data16
  46.  
  47. ;------------------------------------------------------------------------
  48.  
  49.     .286c
  50.     start_bss
  51.  
  52.     public  _i_tss
  53. _i_tss  label    tss_s
  54.     db    type tss_s dup (?)
  55.  
  56.     public  _v74_tss
  57. _v74_tss    label    tss_s
  58.     db    type tss_s dup (?)
  59.  
  60.     public  _v78_tss
  61. _v78_tss    label    tss_s
  62.     db    type tss_s dup (?)
  63.  
  64.     public  _v79_tss
  65. _v79_tss    label    tss_s
  66.     db    type tss_s dup (?)
  67.  
  68.     end_bss
  69.     .386p
  70.  
  71. ;------------------------------------------------------------------------
  72.  
  73.     start_altcode16
  74.  
  75. sound    macro
  76.     local    foo
  77.     mov    al,033h
  78.     out    061h,al
  79.     mov    cx,0ffffh
  80. foo:
  81.     loop    foo
  82.     endm
  83.  
  84. ivec    macro    n
  85.     push    ds
  86.     push    g_rdata
  87.     pop    ds
  88.     mov    ivec_number,n
  89.     pop    ds
  90.     db    0eah
  91.     dw    0, g_itss
  92.     endm
  93.  
  94.     public  _ivec0, _ivec1
  95. _ivec0:
  96.     ivec 0
  97. _ivec1:
  98.     x=1
  99.     rept 255
  100.      ivec x
  101.      x=x+1
  102.     endm
  103.  
  104.     end_altcode16
  105.     start_code16
  106.  
  107.     public  _interrupt_common
  108. _interrupt_common:
  109.     cli
  110.     mov    bx,g_rdata
  111.     mov    ds,bx
  112.     mov    bx,_tss_ptr
  113.     mov    al,ivec_number
  114.     mov    [bx].tss_irqn,al
  115.     mov    esi,[bx].tss_esp
  116.     mov    fs,[bx].tss_ss        ; fs:esi -> stack
  117.     cmp    al,16
  118.     ja    has_no_error
  119.     mov    ah,0
  120.     mov    di,ax
  121.     cmp    has_error[di],0
  122.     je    has_no_error
  123.     mov    eax,fs:[esi]
  124.     mov    [bx].tss_error,eax
  125.     add    esi,4
  126. has_no_error:
  127.     mov    eax,fs:[esi]        ; eip
  128.     mov    [bx].tss_eip,eax
  129.     mov    eax,fs:[esi+4]
  130.     mov    [bx].tss_cs,ax
  131.     mov    eax,fs:[esi+8]
  132.     mov    [bx].tss_eflags,eax
  133.     add    esi,12
  134.     mov    [bx].tss_esp,esi    ; store corrected stack pointer
  135.     mov    _was_exception,1
  136.     jmpt    g_ctss            ; pass control back to real mode
  137.     cli
  138.     jmp    _interrupt_common    ; it's a task
  139.  
  140.     extrn    graphics_fault:near
  141.  
  142.     public  _page_fault
  143. _page_fault:
  144.     cli
  145.     mov    bx,g_rdata
  146.     mov    ds,bx
  147.     mov    es,bx
  148.     mov    eax,cr2
  149. if 1
  150. ;;
  151. ;; CB changes: added 16MB paging areas
  152. ;; OLD:
  153. ;;    cmp    eax,0e0000000h
  154. ;;    jb    regular_pf
  155. ;;    cmp    eax,0e0300000h
  156. ;;    ja    regular_pf
  157. ;;
  158.     cmp    eax,0e0000000h
  159.     jb    regular_pf
  160.     cmp    eax,0e0300000h
  161.     jb    graphics_pf
  162.     cmp    eax,0e1000000h
  163.     jb    regular_pf
  164.     cmp    eax,0e4000000h
  165.     jae    regular_pf
  166. graphics_pf:
  167. ;;
  168. ;; end CB changes
  169. ;;
  170.     jmp    graphics_fault
  171. regular_pf:
  172. endif
  173.     mov    bx,_tss_ptr
  174.     mov    [bx].tss_irqn,14    ; page fault
  175.     mov    [bx].tss_cr2,eax
  176.     pop    eax
  177.     mov    [bx].tss_error,eax
  178.     mov    eax,0
  179.     mov    cr2,eax            ; so we can tell INT 0D from page fault
  180.     mov    _was_exception,1
  181.     jmpt    g_ctss
  182.     jmp    _page_fault
  183.  
  184. v_handler    macro    label,vector
  185.     public  label
  186. label:
  187.     cli
  188.     mov    bx,g_rdata
  189.     mov    ds,bx
  190.     mov    es,bx
  191.     mov    bx,_tss_ptr
  192.     mov    al,vector
  193.     mov    [bx].tss_irqn,al
  194.     mov    _was_exception,1
  195.     jmpt    g_ctss
  196.     jmp    label
  197.     endm
  198.  
  199.     v_handler    _v74_handler, 74h
  200.     v_handler    _v78_handler, _vector_78h
  201.     v_handler    _v79_handler, _vector_79h
  202.  
  203.     end_code16
  204.  
  205. ;------------------------------------------------------------------------
  206.  
  207.     end
  208.